/* 全局样式 */
:root {
    --primary-color: #FF7043; /* Rust橙色 */
    --primary-dark: #E64A19;
    --secondary-color: #455A64;
    --light-bg: #F5F5F5;
    --dark-bg: #263238;
    --text-color: #333333;
    --light-text: #FFFFFF;
    --border-color: #DDDDDD;
    --success-color: #4CAF50;
    --warning-color: #FFC107;
    --error-color: #F44336;
    --beginner-color: #4CAF50;
    --intermediate-color: #2196F3;
    --advanced-color: #F44336;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    background-color: var(--dark-bg);
    color: var(--light-text);
    border-radius: 8px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* 主要内容区域 */
main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

h2 {
    margin-bottom: 20px;
    color: var(--secondary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary-color);
}

select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

select:focus, textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* 难度选择器 */
.difficulty-selector, .exercise-type-selector {
    display: flex;
    gap: 15px;
}

.difficulty-selector input[type="radio"],
.exercise-type-selector input[type="radio"] {
    display: none;
}

.difficulty-label, .exercise-type-label {
    flex: 1;
    padding: 12px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.difficulty-label.beginner {
    color: var(--beginner-color);
}

.difficulty-label.intermediate {
    color: var(--intermediate-color);
}

.difficulty-label.advanced {
    color: var(--error-color);
}

input[type="radio"]:checked + .difficulty-label.beginner {
    background-color: var(--beginner-color);
    border-color: var(--beginner-color);
    color: white;
}

input[type="radio"]:checked + .difficulty-label.intermediate {
    background-color: var(--intermediate-color);
    border-color: var(--intermediate-color);
    color: white;
}

input[type="radio"]:checked + .difficulty-label.advanced {
    background-color: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

input[type="radio"]:checked + .exercise-type-label {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* 按钮样式 */
.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn.small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background-color: var(--primary-dark);
}

.btn.secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn.secondary:hover {
    background-color: #37474F;
}

.btn:not(.primary):not(.secondary) {
    background-color: #E0E0E0;
    color: var(--text-color);
}

.btn:not(.primary):not(.secondary):hover {
    background-color: #BDBDBD;
}

/* 练习显示区域 */
.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.exercise-meta {
    display: flex;
    gap: 10px;
}

.topic-badge, .difficulty-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.topic-badge {
    background-color: var(--secondary-color);
    color: white;
}

.difficulty-badge.beginner {
    background-color: var(--beginner-color);
    color: white;
}

.difficulty-badge.intermediate {
    background-color: var(--intermediate-color);
    color: white;
}

.difficulty-badge.advanced {
    background-color: var(--error-color);
    color: white;
}

.exercise-description {
    margin-bottom: 30px;
    line-height: 1.8;
}

/* 代码编辑器 */
.code-editor-container {
    margin-bottom: 30px;
}

.code-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--dark-bg);
    color: var(--light-text);
    padding: 10px 15px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.code-editor {
    border: 1px solid var(--dark-bg);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    overflow: hidden;
}

.code-editor pre {
    margin: 0;
    padding: 15px;
    background-color: #282C34;
    color: #ABB2BF;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: auto;
    min-height: 300px;
}

.code-editor pre code {
    outline: none;
}

/* 输出容器 */
.output-container {
    margin-bottom: 30px;
}

.output {
    background-color: #282C34;
    color: #ABB2BF;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

.exercise-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* 反馈部分 */
.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.score-circle span {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
}

.score-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.feedback-summary {
    background-color: #F5F5F5;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.feedback-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.feedback-category h3 {
    margin-bottom: 15px;
    color: var(--secondary-color);
}

.feedback-category ul {
    list-style-position: inside;
    padding-left: 10px;
}

.feedback-category li {
    margin-bottom: 8px;
}

.solution-container {
    margin-top: 30px;
}

.solution-code {
    background-color: #282C34;
    color: #ABB2BF;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: auto;
}

.feedback-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    position: relative;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
}

/* 页脚 */
footer {
    text-align: center;
    margin-top: 50px;
    padding: 20px;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    section {
        padding: 20px;
    }
    
    .difficulty-selector, .exercise-type-selector {
        flex-direction: column;
        gap: 10px;
    }
    
    .feedback-categories {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
}